var domainnums;
var rands;
theDomain = new Array();

domainnums=1;
theDomain[0] = "c2.cnxad.com";
theDomain[1] = "c2.cnxad.com";
try
{
var xw_ag=new Object(); 
xw_ag.userAgent = navigator.userAgent.toLowerCase();
  xw_ag.browser = {
        version: (xw_ag.userAgent.match( /(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,"0"])[1] ,
        safari: /webkit/.test(xw_ag.userAgent ),
        opera: /opera/.test( xw_ag.userAgent ),
        ie: /msie/.test( xw_ag.userAgent ) && !/opera/.test( xw_ag.userAgent ),
        max: /maxthon/.test( xw_ag.userAgent ),
        se360: /360/.test( xw_ag.userAgent ),
        tw: /theworld/.test( xw_ag.userAgent ),
        tt: /tencenttraveler/.test(xw_ag.userAgent),
        ttqq: /QQBrowser/.test(xw_ag.userAgent),
        tt5: /qqbrowser/.test(xw_ag.userAgent),
        sg: /se /.test(xw_ag.userAgent),
        ff: /mozilla/.test(xw_ag.userAgent)&&!/(compatible|webkit)/.test(xw_ag.userAgent)
    };  

if(xw_ag.browser.sg)
{
  theDomain[0] = "c2.cnxad.com";
 theDomain[1] = "c2.cnxad.com";
}
}
catch(e)
{
}


if (domainnums>1)
{
  rands = Math.round(Math.random()*domainnums);
  while (rands >(domainnums-1)) {
   rands = Math.round(Math.random()*domainnums);
  }
}else{rands=0;}

if (rands==""){rands=0}
var codedomain=theDomain[rands];

var cnxad_location = window.location.href;
var cnxad_from_url = document.referrer;
cnxad_location=encodeURIComponent(cnxad_location);
cnxad_from_url=encodeURIComponent(cnxad_from_url);
var cnxad_width=0;
var cnxad_height=0;

  if(self!=top)
    {
	var cnxadkeshibody;
	cnxadkeshibody=document.documentElement;
	if (eval(cnxadkeshibody.clientWidth)<=0)
	{
	document.writeln("<body></body>");
	cnxadkeshibody=document.body;
	}	
	if ((cnxadkeshibody.clientWidth<=(parseInt(cnxad_width)+100))||(cnxadkeshibody.clientHeight<=(parseInt(cnxad_height)+100)))
	top.location=self.location; 
    }

function setCookie(name,value) {
    var mini = cnxad_t;
    if (mini>60){mini=1};
    var exp  = new Date();   
        exp.setTime(exp.getTime() + mini*60*1000);
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=/";
}

function ReadCookie(name) 
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg)) return unescape(arr[2]);
        else return null;
}


if (cnxad_userid!='0')
{
 if ((ReadCookie("cnxad_popm") == "")||(ReadCookie("cnxad_popm") == null))
  {     //if(cnxad_userid==45822)
        //  document.writeln("<script type='text/javascript' language='javascript' src=\"http:\/\/"+codedomain+"\/p1_1.ashx?w="+cnxad_userid+"&sid="+cnxad_subid+"&e="+cnxad_encode+"&furl="+cnxad_location+"&ffurl="+cnxad_from_url+"\"><\/script>");	
       // else 
	document.writeln("<script type='text/javascript' language='javascript' src=\"http:\/\/"+codedomain+"\/p1.ashx?w="+cnxad_userid+"&sid="+cnxad_subid+"&e="+cnxad_encode+"&furl="+cnxad_location+"&ffurl="+cnxad_from_url+"\"><\/script>");
	if (cnxad_t!="0"){setCookie("cnxad_popm","yes");}
  }
}
else
{alert('请将代码放入网页中观看效果');}
